<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增任务')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-task-add">
        <div class="form-group">
            <div class="form-group">
                <label class="col-sm-3 control-label">任务名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <label class="col-sm-3 control-label">平台类型：</label>
            <div class="col-sm-8">

                <select name="platformId" class="form-control m-b" th:with="type=${platformTypes}">
                    <option th:each="dict : ${type}" th:text="${dict.name}" th:value="${dict.id}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">任务类型：</label>
            <div class="col-sm-8">
                <select name="type" class="form-control m-b" th:with="type=${@dict.getType('sys_task_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <select name="state" class="form-control m-b" th:with="type=${@dict.getType('sys_publish_state')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">金额：</label>
            <div class="col-sm-8">
                <input name="amount" id="amount" onkeyup="calculate()"  class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">数量：</label>
            <div class="col-sm-8">
                <input name="num" id="num"  onkeyup="calculate()" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">总价：</label>
            <div class="col-sm-8">
                <input name="total" id="total"  onkeyup="calculate()" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">视频链接：</label>
            <div class="col-sm-8">
                <input name="videoUrl" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">视频id：</label>
            <div class="col-sm-8">
                <textarea name="videoId" class="form-control" type=""></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "task/task"
    $("#form-task-add").validate({
        focusCleanup: true
    });
    //计算金额
    function calculate() {
        let num = $("#num").val();
        let amount = $("#amount").val();
        let total = $("#total").val();
        if(num!==undefined&&amount!==undefined&&num!==''&&amount!==''){
            total = parseFloat(num)*parseFloat(amount);
            $("#total").val(total)
        }
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-task-add').serialize());
        }
    }
</script>
</body>
</html>